<%var userIsRequesting=request.facebook_user.id==facebookUserId;%>
<%if(userIsRequesting){
	var thisUserAgreed=requester_agreed;
	var otherUserAgreed=item_owner_agreed;
}else{
	var thisUserAgreed=item_owner_agreed;
	var otherUserAgreed=requester_agreed;
}%>
<div class="cardlet">
	<table style="width:100%">
		<%if(thisUserAgreed && otherUserAgreed){%>
			<tr><td class="cardlet-offer-description">
					<%if(userIsRequesting){%>
						Borrowed <%=item.name%> from <%=facebookUser(item)%>.
					<%}else{%>
						Lended <%=item.name%> to <%=facebookUser(request)%>.
					<%}%>
			</td></tr>
			<tr><td class="cardlet-offer-due">
					<%=userIsRequesting ? 'You' : 'They'%>
					need to return it on <%=return_due_date%>.
			</td></tr>
			<tr><td class="cardlet-offer-due">
					<%var daysTillReturn=dayDiff(Date.now(),return_due_date)%>
					<%if(0<daysTillReturn){%>
						That's <%=daysTillReturn%> days from now.
					<%}else if(daysTillReturn<0){%>
						<span class="return-overdue">
							That was <%=-daysTillReturn%> days ago!
						</span>
					<%}else{%>
						<span class="return-today">
							That's today!
						</span>
					<%}%>
			</td></tr>
		<%}else{%>
			<tr><td class="cardlet-offer-description">
					<%if(userIsRequesting){%>
						<%if(thisUserAgreed){%>
							You requested from <%=facebookUser(item)%> to borrow their <%=item.name%>.
						<%}else if(otherUserAgreed){%>
							<%=facebookUser(item)%> offer to lend you their <%=item.name%>.
						<%}%>
					<%}else{%>
						<%if(thisUserAgreed){%>
							You offered to lend your <%=item.name%> to <%=facebookUser(item)%>.
						<%}else if(otherUserAgreed){%>
							<%=facebookUser(request)%> want to borrow your <%=item.name%>
						<%}%>
					<%}%>
			</td></tr>
			<tr><td>
					<%if(thisUserAgreed){%>
						Still waiting for answer.
					<%}else if(otherUserAgreed){%>
						<form>
							<%=hidden_field_tag('offer_id',id)%>
							<button
								action="offers#accept"
								trigger_along="reload-offers"
								data-callback="logResponse"
								>Accept!</button>
						</form>
					<%}%>
			</td></tr>
		<%}%>
	</table>
</div>
